package gameStates.gui;

import gameStates.absGamesStates.gui.AbsScoreBoardState;
import gameStates.passes.AbsPassManagerState;
import interfaces.hud.end.ScoreBoardWindow;
import logic.common.game.Game;

/**
 * This {@link GUIState} shows a table with all information of the {@link Team}s and their current 
 * {@link Player}s. These information will be displayed by a {@link ScoreBoardWindow}.
 * 
 * @author Wasserleiche
 */
public class ScoreBoardState extends AbsScoreBoardState {
		
	/** The {@link ScoreBoardWindow} that is used by this ShowPlayersState. */
	private ScoreBoardWindow scoreBoardWindow;
	/** The {@link Game} whose {@link Player}s shall be displayed. */
	private Game game;
	
	/**
	 * Constructs a new ShowPlayersState with the given {@link Game}. A new {@link ScoreBoardWindow} will 
	 * be created here.
	 * @param game The {@link Game} that contains the {@link Team}s whose {@link Player}s shall be 
	 * displayed.
	 */
	public ScoreBoardState(Game game, AbsPassManagerState passManagerState) {
		super(passManagerState, true);
		this.game = game;
		
		initInterface();
	}
	
	/**
	 * Creates a new {@link ScoreBoardWindow} and attaches it to the display.
	 */
	public void initInterface() {
		int border = getHeight() / ScoreBoardWindow.BORDER_FACTOR;
		int height = getHeight() - (2 * border);
		int width = getWidth() - (2 * border);
		scoreBoardWindow = new ScoreBoardWindow(game, width, height, border, border, this);
		scoreBoardWindow.addToContainer(guiDisp);
		guiDisp.layout();
	}
	
	/**
	 * Restores this ShowPlayersState. A new {@link ScoreBoardWindow} will be created, too.
	 */
	@Override
	public void restore() {
		super.restore();
		initInterface();
	}
}